package com.imti.mall.product.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.imti.mall.model.pms.pojo.PmsProductFullReduction;
import com.imti.mall.model.pms.pojo.PmsSkuStock;
import com.imti.mall.product.dao.PmsProductFullReductionDao;
import com.imti.mall.product.dao.PmsSkuStockDao;
import com.imti.mall.product.service.PmsSkuStockService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class PmsSkuStockServiceImpl extends ServiceImpl<PmsSkuStockDao, PmsSkuStock> implements PmsSkuStockService {

    @Autowired
    PmsSkuStockDao pmsSkuStockDao;
    /**
     * 根据商品id查询SKU
     * @param id
     * @return
     */
    @Override
    public List<PmsSkuStock> getPmsSkuStockproductProductId(Integer id) {
        return pmsSkuStockDao.getPmsSkuStockproductProductId(id);
    }
    /**
     * 根据商品id和SKU编号查询SKU数据
     * @param id
     * @return
     */
    @Override
    public PmsSkuStock getPmsSkuStockproductProductSkuCode(Integer id, String skuCode) {
        return pmsSkuStockDao.getPmsSkuStockproductProductSkuCode(id,skuCode);
    }
    /**
     * 根据id修改查询SKU数据
     * @param pmsSkuStock
     * @return
     */
    @Override
    public Integer updateSkuStockById(PmsSkuStock pmsSkuStock) {
        return pmsSkuStockDao.updateSkuStockBy(pmsSkuStock);
    }

    /**
     * 根据id删除信息
     * @param id
     * @return
     */
    @Override
    public Integer delSkuStockById(Integer id) {
        return pmsSkuStockDao.deleteById(id);
    }

    /**
     * 添加sku信息
     * @param pmsSkuStock
     * @return
     */
    @Override
    public Integer addSkuStockById(PmsSkuStock pmsSkuStock) {
        return pmsSkuStockDao.insert(pmsSkuStock);
    }


    /**
     * 批量添加
     * @param list
     * @return
     */
    @Override
    public boolean addList(List<PmsSkuStock> list){
        return  saveBatch(list);
    }

    /**
     * 批量修改
     * @param list
     * @return
     */
    @Override
    public boolean updateList(List<PmsSkuStock> list){
        return saveOrUpdateBatch(list);
    }

    @Override
    public boolean deleteList(List<PmsSkuStock> list) {
        return removeByIds(list);
    }
}
